//
//  PMeController.swift
//  CJPack
//
//  Created by 陈警卫 on 2024-07-15.
//

import UIKit

class PMeController: CJBaseMenuController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let skinL = UILabel(frame: CGRect(x: 20, y: CJScreen.navBatBarHeight + 20, width: 50, height: 50))
        skinL.text = "主题"
        skinL.cj_textColorkey = CJPColor.fore.key
        view.addSubview(skinL)
        
        let skinSw = UISwitch(frame: CGRectMake(skinL.cj_right + 10, 0, 50, 50))
        skinSw.cj_centerY = skinL.cj_centerY
        view.addSubview(skinSw)
        skinSw.addTarget(self, action: #selector(skinSwAction(sw:)), for: .valueChanged)
        
        skinSw.isOn = CJSkin.shared.currentSkinKey != "any"
        
        let btn = UIButton(type: .custom)
        btn.frame = CGRect(x: 20, y: skinL.cj_bottom + 20, width: 100, height: 50)
        //btn.setTitleColor(CJPColor.fore.color, for: .normal)
        //btn.backgroundColor = CJPColor.theme.color
        btn.cj_textColorkey = CJPColor.fore.key
        btn.cj_backroundColorkey = CJPColor.theme.key
        btn.setTitle("Skin", for: .normal)
        view.addSubview(btn)
    }
}

extension PMeController {
    
    @objc func skinSwAction(sw: UISwitch) {
        if sw.isOn {
            CJSkin.shared.setCurrentSkin(key: "dark")
        } else {
            CJSkin.shared.setCurrentSkin(key: "any")
        }
    }
    
}
